<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }

    img {
      width: 300px;
      display: block;
      margin: 100px auto;
    }
  </style>
</head>

<body>
  <img src="https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3281904817,1077646612&fm=26&gp=0.jpg"
    data-src="./img/1.jpg" alt="">
  <img src="https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3281904817,1077646612&fm=26&gp=0.jpg"
    data-src="./img/2.jpg" alt="">
  <img src="https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3281904817,1077646612&fm=26&gp=0.jpg"
    data-src="./img/3.jpg" alt="">
  <img src="https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3281904817,1077646612&fm=26&gp=0.jpg"
    data-src="./img/4.jpg" alt="">
  <img src="https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3281904817,1077646612&fm=26&gp=0.jpg"
    data-src="./img/5.jpg" alt="">
  <img src="https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3281904817,1077646612&fm=26&gp=0.jpg"
    data-src="./img/1.jpg" alt="">

  <script>
    const images = document.querySelectorAll('img')
    const observer = new IntersectionObserver(nodes => {
      nodes.forEach(v => {
        if (v.isIntersecting) {
          v.target.src = v.target.dataset.src
          observer.unobserve(v.target)
        }
      })
    })
    images.forEach(v => observer.observe(v))
  </script>
</body>

</html>